<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta property="og:type" content="website">
<meta property="og:title" content="smallmuou&#39;s blog">
<meta property="og:url" content="http://smallmuou.gitee.io/blog/page/17/index.html">
<meta property="og:site_name" content="smallmuou&#39;s blog">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="smallmuou&#39;s blog">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://smallmuou.gitee.io/blog/page/17/"/>





  <title>smallmuou's blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">smallmuou's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"><a href="https://github.com/smallmuou">https://github.com/smallmuou</a></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/06/11/2015-06-11-命令行查看iOS设备的UUID(system_profiler)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/06/11/2015-06-11-命令行查看iOS设备的UUID(system_profiler)/" itemprop="url">命令行查看iOS设备的UUID(system_profiler)</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-06-11T00:00:00+08:00">
                2015-06-11
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/IOS/" itemprop="url" rel="index">
                    <span itemprop="name">IOS</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>每次要查看iOS设备的UUID，都要打开iTool或iTunes，显得非常麻烦，有没有更简单的方式，经过Google发现真有，现将此命令记录于此。</p>
<h2 id="1-获取UUID"><a href="#1-获取UUID" class="headerlink" title="1. 获取UUID"></a>1. 获取UUID</h2><pre>
system_profiler SPUSBDataType | sed -n  -e '/iPad/,/Extra/p' -e '/iPhone/,/Extra/p'
</pre>
PS: 

* SPUSBDataType 表示USB类型数据
* sed -n 表示不打印每行内容
* sed -e 追加命令
* /iPad/,/Extra/p 查找并打印iPad与Extra之间的内容

输出
<pre>
StarnetdeMacBook-Pro:ResearchKit starnet$ system_profiler SPUSBDataType | sed -n  -e '/iPad/,/Extra/p'
        iPad:
          Product ID: 0x12ab
          Vendor ID: 0x05ac  (Apple Inc.)
          Version: 4.01
          Serial Number: 690a505acd5ea06233a2c10c173907c135070ace
          Speed: Up to 480 Mb/sec
          Manufacturer: Apple Inc.
          Location ID: 0x14100000 / 7
          Current Available (mA): 500
          Current Required (mA): 500
          Extra Operating Current (mA): 1600
</pre>

<h2 id="2-system-profiler"><a href="#2-system-profiler" class="headerlink" title="2. system_profiler"></a>2. system_profiler</h2><p>system_profiler是MACOSX提供的命令，用于查看软硬件配置，可以用<code>man system_profiler</code> 查看帮助.</p>
<ul>
<li><p>使用方法</p>
<pre>
system_profiler datatype #查看datatype类型的配置
</pre>
</li>
<li><p>如何获取datatype</p>
<pre>
system_profiler -listDataTypes
</pre>
可以得出如下内容:
<pre>
Available Datatypes:
SPParallelATADataType
SPUniversalAccessDataType
SPApplicationsDataType
SPAudioDataType
SPBluetoothDataType
SPCameraDataType
SPCardReaderDataType
SPComponentDataType
SPDeveloperToolsDataType
SPDiagnosticsDataType
SPDisabledSoftwareDataType
SPDiscBurningDataType
SPEthernetDataType
SPExtensionsDataType
SPFibreChannelDataType
SPFireWireDataType
SPFirewallDataType
SPFontsDataType
SPFrameworksDataType
SPDisplaysDataType
SPHardwareDataType
SPHardwareRAIDDataType
SPInstallHistoryDataType
SPNetworkLocationDataType
SPLogsDataType
SPManagedClientDataType
SPMemoryDataType
SPNetworkDataType
SPPCIDataType
SPParallelSCSIDataType
SPPowerDataType
SPPrefPaneDataType
SPPrintersSoftwareDataType
SPPrintersDataType
SPConfigurationProfileDataType
SPSASDataType
SPSerialATADataType
SPSPIDataType
SPSoftwareDataType
SPStartupItemDataType
SPStorageDataType
SPSyncServicesDataType
SPThunderboltDataType
SPUSBDataType
SPNetworkVolumeDataType
SPWWANDataType
SPAirPortDataType
</pre>
</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/06/05/2015-06-05-Ruby学习路程/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/06/05/2015-06-05-Ruby学习路程/" itemprop="url">Ruby学习路程</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-06-05T00:00:00+08:00">
                2015-06-05
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/其他/" itemprop="url" rel="index">
                    <span itemprop="name">其他</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>Ruby是另一种脚本语言，为什么说“又”，因为我已经了解了lua和python，那么为什么要学习Ruby，最主要的原因是现在很多第三方工具，如Cocoapods、Jekyll是用Ruby写的，为了更好的了解他们，至少得看得懂Ruby语法，于是就有了该Blog，我会将我学习Ruby的经历记录与此。</p>
<h3 id="0-HelloWorld"><a href="#0-HelloWorld" class="headerlink" title="0. HelloWorld"></a>0. HelloWorld</h3><p>任何语言都是从HelloWorld开始，Ruby也不另外.</p>
<pre>
puts "Hello Ruby World."
</pre>
纳尼，就这一句？没错！！！ 看看输出:
<pre>
StarnetdeMacBook-Pro:ruby starnet$ ruby helloworld.rb 
Hello Ruby World
</pre>

<h3 id="1-语法"><a href="#1-语法" class="headerlink" title="1. 语法"></a>1. 语法</h3><ul>
<li>如果 Ruby 在行尾遇到运算符，比如 +、- 或反斜杠，它们表示一个语句的延续</li>
<li>Ruby 标识符的名称可以包含字母、数字和下划线字符（ _ ）</li>
<li><p>&lt;&lt; 多行字符串</p>
<pre>
print << (此处不应有空格) EOF
  This is the first way of creating
  here document ie. multiple line string.
EOF
</pre>
</li>
<li><p>BEGIN 在程序之前执行</p>
<pre>
BEGIN {
 code
}</pre>
</li>
<li><p>END 在程序之后执行</p>
<pre>
END {
 code
}</pre>
</li>
<li><p>#为注释符号</p>
</li>
</ul>
<h3 id="2-变量"><a href="#2-变量" class="headerlink" title="2. 变量"></a>2. 变量</h3><ul>
<li><p>$ - 全局变量</p>
<pre>
$: 默认搜索路径
$! 最近一次的错误信息
$@ 错误产生的位置
$_ gets最近读的字符串
$. 解释器最近读的行数(line number)
$& 最近一次与正则表达式匹配的字符串
$~ 作为子表达式组的最近一次匹配
$n 最近匹配的第n个子表达式(和$~[n]一样)
$= 是否区别大小写的标志
$/ 输入记录分隔符
$\ 输出记录分隔符
$0 Ruby脚本的文件名
$* 命令行参数
$$ 解释器进程ID
$? 最近一次执行的子进程退出状态</pre>
</li>
<li><p>@ - 类实例成员变量</p>
</li>
<li>@@ - 类变量</li>
<li>大写 - 常量</li>
<li>:: - 域</li>
<li><p>: - symbol</p>
<ul>
<li>名字相同， Symbol 相同</li>
<li>名字不同， Symbol 不同</li>
</ul>
</li>
<li><p>伪变量</p>
<pre>
self: 当前方法的接收器对象
true: 代表 true 的值
false: 代表 false 的值
nil: 代表 undefined 的值
__FILE__: 当前源文件的名称
__LINE__: 当前行在源文件中的编号
</pre>

</li>
</ul>
<h3 id="3-逻辑代码段"><a href="#3-逻辑代码段" class="headerlink" title="3. 逻辑代码段"></a>3. 逻辑代码段</h3><ul>
<li><p>if…else</p>
<pre>
if conditional [then]
    code...
[elsif conditional [then]
    code...]...
[else
    code...]
end
</pre>
</li>
<li><p>if</p>
<pre>
code if condition
</pre>
</li>
<li><p>unless…else = if反义</p>
<pre>
unless conditional [then]
 code
[else
 code ]
end
</pre>
</li>
<li><p>unless</p>
<pre>
code unless conditional
</pre>
</li>
<li><p>case</p>
<pre>
case expression
[when expression [, expression ...] [then]
 code ]...
[when expression [, expression ...] [then]
 code ]...
...
[else
 code ]
end
</pre>
</li>
<li><p>while</p>
<pre>
while conditional [do]
 code
end
</pre>
<pre>
code while condition
或者
begin 
code 
end while conditional
</pre>
</li>
<li><p>until - while反义</p>
<pre>
until conditional [do]
 code
end
</pre>

</li>
</ul>
<pre>
code until conditional
或者
begin
   code
end until conditional
</pre>

<ul>
<li><p>for</p>
<pre>
for variable [, variable ...] in expression [do]
 code
end
</pre>
</li>
<li><p>redo</p>
<pre>
for i in 0..5
 if i < 2 then
    puts "Value of local variable is #{i}"
    redo
 end
end
</pre>
</li>
<li><p>retry</p>
<pre>
begin
 do_something # 抛出的异常
rescue
 # 处理错误
 retry  # 重新从 begin 开始
end
</pre>
</li>
<li><p>do</p>
<pre>
(expression).each do |variable[, variable...]| code end
</pre>

</li>
</ul>
<h3 id="4-方法与块"><a href="#4-方法与块" class="headerlink" title="4. 方法与块"></a>4. 方法与块</h3><ul>
<li><p>方法</p>
<pre>
def method_name [( [arg [= default]]...[, * arg [, &expr ]])]
 expr..
end
</pre>
<pre>
method_name [arg ...]
</pre>
</li>
<li><p>块</p>
<pre>
block_name{
 statement1
 statement2
 ..........
}
</pre>
yield 表示{}
在块中，您可以在两个竖线之间放置一个变量来接受参数
<pre>
def test
 yield 5,10
 puts "You are in the method test"
 yield 100,200
end
test {|i,j| puts "You are in the block #{i}, #{j}"}
</pre>

</li>
</ul>
<h3 id="5-lt-lt-self-理解"><a href="#5-lt-lt-self-理解" class="headerlink" title="5. \&lt;\&lt; self 理解"></a>5. \&lt;\&lt; self 理解</h3><p>查考<a href="http://blog.csdn.net/lyx2007825/article/details/10089115" target="_blank" rel="noopener">这里</a><br>ruby在任何时间任何地点，可以对一个类或对象打开进行添加方法或者重写方法 其本质是<strong>ruby在任何地方能对一个既存的对象打开也是基于类的，只不过是个匿名的内部类而已，而这个类继承于当前实例的类</strong></p>
<p>于是 &lt;&lt; self 可以理解为重写self的类方法</p>
<pre>
class Hello
    class << self
        def hello
            puts 'hello'
        end
        def hello1
            hello
            puts 'hello1'
        end
    end  
    def hello2 
        Hello.hello
        puts 'hello2'
    end
    def self.hello3
        Hello.hello
        puts 'hello2'
    end
end
Hello.hello
Hello.hello3
h = Hello.new
h.hello2
</pre>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/05/18/2015-05-18-iOS APP图标一键生成/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/05/18/2015-05-18-iOS APP图标一键生成/" itemprop="url">iOS APP图标一键生成</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-05-18T00:00:00+08:00">
                2015-05-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/IOS/" itemprop="url" rel="index">
                    <span itemprop="name">IOS</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>随着工龄的渐长，发觉越来越懒，对于繁琐的事情，总想少干点，就像今天提及的APP图标这个事，往常的做法无非是两种，一是让UI工程师提供所有尺寸的图标，二是UI工程师给出一个大图标，自己缩小，方法一可谓是害己又害人，虽然开发者的工作量少，但一旦图标调整，苦了UI工程师，又累了开发者（要自己替换图标）；方法二，那可是够累，打开PS，调整图像大小，保存，调整图像大小，保存…，今天可谓终于忍无可忍，决定写一个脚本<a href="https://github.com/smallmuou/ios-icon-generator" target="_blank" rel="noopener">ios-icon-generator</a>，下面简单介绍下.</p>
<h3 id="环境预备"><a href="#环境预备" class="headerlink" title="环境预备"></a>环境预备</h3><p>它是一个shell脚本，可以在MACOSX的bash直接运行，它依赖于强大的ImageMagick，因此在使用它之前，请先安装ImageMagick</p>
<pre>
sudo brew install ImageMagick
</pre>

<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><pre>
git clone https://github.com/smallmuou/ios-icon-generator
cd ios-icon-generator
chmod 777 ios-icon-generator.sh
</pre>

<h3 id="运行"><a href="#运行" class="headerlink" title="运行"></a>运行</h3><pre>
StarnetdeMacBook-Pro:ios-icon-generator starnet$ ./ios-icon-generator.sh ~/Downloads/1024.png ~/output
[INFO] Generate iTunesArtwork.png ...
[INFO] Generate iTunesArtwork@2x.png ...
[INFO] Generate Icon-Small.png ...
[INFO] Generate Icon-Small@2x.png ...
[INFO] Generate Icon-Small@3x.png ...
[INFO] Generate Icon-Small-40.png ...
[INFO] Generate Icon-Small-40@2x.png ...
[INFO] Generate Icon-Small-40@3x.png ...
[INFO] Generate Icon-60.png ...
[INFO] Generate Icon-60@2x.png ...
[INFO] Generate Icon-60@3x.png ...
[INFO] Generate Icon-76.png ...
[INFO] Generate Icon-76@2x.png ...
[INFO] Generate Icon.png ...
[INFO] Generate Icon@2x.png ...
[INFO] Generate Icon-72.png ...
[INFO] Generate Icon-72@2x.png ...
[INFO] Generate Icon-Small-50.png ...
[INFO] Generate Icon-Small-50@2x.png ...
[INFO] Generate Done.
</pre>

<h3 id="结果"><a href="#结果" class="headerlink" title="结果"></a>结果</h3><pre>
StarnetdeMacBook-Pro:ios-icon-generator starnet$ ls -l ~/output/
total 288
-rw-r--r--  1 starnet  staff   1921 May 18 17:45 Icon-60.png
-rw-r--r--  1 starnet  staff   4723 May 18 17:45 Icon-60@2x.png
-rw-r--r--  1 starnet  staff   6954 May 18 17:45 Icon-60@3x.png
-rw-r--r--  1 starnet  staff   2210 May 18 17:45 Icon-72.png
-rw-r--r--  1 starnet  staff   5565 May 18 17:45 Icon-72@2x.png
-rw-r--r--  1 starnet  staff   2184 May 18 17:45 Icon-76.png
-rw-r--r--  1 starnet  staff   5856 May 18 17:45 Icon-76@2x.png
-rw-r--r--  1 starnet  staff   1437 May 18 17:45 Icon-Small-40.png
-rw-r--r--  1 starnet  staff   3267 May 18 17:45 Icon-Small-40@2x.png
-rw-r--r--  1 starnet  staff   4723 May 18 17:45 Icon-Small-40@3x.png
-rw-r--r--  1 starnet  staff   1674 May 18 17:45 Icon-Small-50.png
-rw-r--r--  1 starnet  staff   3992 May 18 17:45 Icon-Small-50@2x.png
-rw-r--r--  1 starnet  staff   1168 May 18 17:45 Icon-Small.png
-rw-r--r--  1 starnet  staff   1786 May 18 17:45 Icon-Small@2x.png
-rw-r--r--  1 starnet  staff   2393 May 18 17:45 Icon-Small@3x.png
-rw-r--r--  1 starnet  staff   1828 May 18 17:45 Icon.png
-rw-r--r--  1 starnet  staff   4491 May 18 17:45 Icon@2x.png
-rw-r--r--  1 starnet  staff  19995 May 18 17:45 iTunesArtwork.png
-rw-r--r--  1 starnet  staff  30653 May 18 17:45 iTunesArtwork@2x.png
</pre>

<h3 id="综述"><a href="#综述" class="headerlink" title="综述"></a>综述</h3><p>该脚本使用起来非常简单，需要的朋友欢迎使用.</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/05/07/2015-05-07-命令行下播放yuedu.fm的文章/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/05/07/2015-05-07-命令行下播放yuedu.fm的文章/" itemprop="url">命令行下播放yuedu.fm的文章</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-05-07T00:00:00+08:00">
                2015-05-07
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/工具/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>一直喜欢<a href="http://yuedu.fm/" target="_blank" rel="noopener">yuedu.fm</a>里的文章，本来想弄个APP，结果API不开放，后来偶然间发现网页中竟然带有mp3路径的字段，这不是给我留漏洞，此时若不钻，天理不容^-^，通过curl、awk就能获取到MP3的url，再利用mplayer，就可以在命令下播放，再加上随机函数，就可以随机播放yuedu.fm的文章，</p>
<pre>
StarnetdeMacBook-Pro:wenva.github.com starnet$ curl http://yuedu.fm/article/1/ | awk -F: '/mp3:/{print $2}'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 26801  100 26801    0     0  45946      0 --:--:-- --:--:-- --:--:-- 45892
"/static/file/pod/daa1915c50d3b23439cdcb7d8ae4c231.mp3"
</pre>
PS：“http://yuedu.fm/article/1/”中的“1”表示文章1，可以为1到1000（目前好像就到900多，猜测应该是文章序号）


下面是我写shell的脚本，可以随机播放.
<pre>
#!/bin/bash
base_url="http://yuedu.fm"

function rand() {
    min=$1  
    max=$(($2-$min+1))  
    num=$(($RANDOM+1000000000))
    echo $(($num%$max+$min))  
}

function get_url() {
    uri=`curl $base_url/article/$1/ | awk -F: '/mp3:/{print $2}'| sed 's/\"//g'`
    echo "$base_url$uri"
}

`pkill mplayer`

while true
do

on=`ps|awk '/mplayer/{print $0}'|grep mp3`

if [ -z "$on" ]; then
    url=$(get_url $(rand 1 1000))
    echo "Play:$url"
    `mplayer $url`&
fi

sleep 10

done
</pre>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/05/06/2015-05-06-MacOSX命令行播放音乐/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/05/06/2015-05-06-MacOSX命令行播放音乐/" itemprop="url">MacOSX命令行播放音乐</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-05-06T00:00:00+08:00">
                2015-05-06
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/工具/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>为啥要在命令行下播放音乐呢？直接利用iTunes播放不行吗？确实，在命令行下播放音乐，显得折腾，但有时你在命令下正敲着命令，结果发现太安静了，想听听歌，怎么办呢？没错，这个主题就是在这个背景下提出的。</p>
<p>已习惯奔波于命令行间，命令行可谓是程序世界里的一朵奇葩，有了它，你可以装各种逼，再经过稍加修饰，比如把背景设成黑色，那估计都被看成了黑客，不过话说回来，对于多媒体的播放，命令行就比较吃力，特别是视频，目前我是没见到在命令行下直接呈现出视频，而对于声音，还是比较好控制的，下面我来讲讲在命令行下如何播放音乐.</p>
<h3 id="afplay"><a href="#afplay" class="headerlink" title="afplay"></a>afplay</h3><pre>
StarnetdeMacBook-Pro:~ starnet$ afplay --help

    Audio File Play
    Version: 2.0
    Copyright 2003-2013, Apple Inc. All Rights Reserved.
    Specify -h (-help) for command options

Usage:
afplay [option...] audio_file

Options: (may appear before or after arguments)
  {-v | --volume} VOLUME
    set the volume for playback of the file
  {-h | --help}
    print help
  { --leaks}
    run leaks analysis
  {-t | --time} TIME
    play for TIME seconds
  {-r | --rate} RATE
    play at playback rate
  {-q | --rQuality} QUALITY
    set the quality used for rate-scaled playback (default is 0 - low quality, 1 - high quality)
  {-d | --debug}
    debug print output
</pre>
PS: afplay xxxx.mp3
不过遗憾的是，afplay只能播放本地歌曲，那我要听网络歌曲呢，那就要用到下面提到的mplayer

### mplayer
mplayer可谓是个强大的播放器，可以通过brew安装，非常方便，安装完后可以使用mplayer xxxx.mp3
不过播放音乐有个蛋疼的地方，需要前台执行，那可不好玩，我还得干其他事呢，怎么办呢？
<pre>
mplayer xxxx.mp3 < /dev/null &
</pre>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/04/29/2015-04-29-为博客添加多说评论/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/04/29/2015-04-29-为博客添加多说评论/" itemprop="url">为博客添加 多说 评论</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-04-29T00:00:00+08:00">
                2015-04-29
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/其他/" itemprop="url" rel="index">
                    <span itemprop="name">其他</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>博客少了评论，总感觉缺(chun)少(shu)灵(che)魂(dan)，今天可算是抽了点时间，集成了一个多说评论，为什么用多说，因为它排行第一 ^-^. 下面记录下Jekyll中添加多说评论步骤.</p>
<h3 id="1-注册并登陆"><a href="#1-注册并登陆" class="headerlink" title="1. 注册并登陆"></a>1. 注册并登陆</h3><p>进入多说官网, 或猛戳<a href="http://duoshuo.com/" target="_blank" rel="noopener">这里</a>，可以用社交账号登陆，如扣扣(QQ), 豆瓣, 百度等等，方便的一塌糊涂.<br><img src="http://7ximmr.com1.z0.glb.clouddn.com/duoshuo_install_0.jpg" alt="image"></p>
<h3 id="2-安装"><a href="#2-安装" class="headerlink" title="2. 安装"></a>2. 安装</h3><p><img src="http://7ximmr.com1.z0.glb.clouddn.com/duoshuo_install_1.jpg" alt="image"></p>
<p>点击上面的“我要安装”会进入到如下界面</p>
<p><img src="http://7ximmr.com1.z0.glb.clouddn.com/duoshuo_install_2.jpg" alt="image"></p>
<p>填写必要的信息，点击“创建”会给出如下Code</p>
<p><img src="http://7ximmr.com1.z0.glb.clouddn.com/duoshuo_install_3.jpg" alt="image"></p>
<h3 id="3-定制"><a href="#3-定制" class="headerlink" title="3. 定制"></a>3. 定制</h3><p>修改上面的代码，主要修改以下几个地方:</p>
<ul>
<li>data-thread-key</li>
<li>data-title</li>
<li>data-url</li>
</ul>
<p>详见我的Code</p>
<p><img src="http://7ximmr.com1.z0.glb.clouddn.com/duoshuo_install_4.jpg" alt="image"></p>
<h3 id="4-添加到Jekyll"><a href="#4-添加到Jekyll" class="headerlink" title="4. 添加到Jekyll"></a>4. 添加到Jekyll</h3><p>将如上代码加入到_layouts/post.html中，不多说，上Code</p>
<p><img src="http://7ximmr.com1.z0.glb.clouddn.com/duoshuo_install_5.jpg" alt="image"></p>
<h3 id="5-Done"><a href="#5-Done" class="headerlink" title="5. Done"></a>5. Done</h3><p>不要惊讶，就是这么简单! 看看效果</p>
<p><img src="http://7ximmr.com1.z0.glb.clouddn.com/duoshuo_install_6.jpg" alt="image"></p>
<h3 id="6-如何管理评论"><a href="#6-如何管理评论" class="headerlink" title="6. 如何管理评论"></a>6. 如何管理评论</h3><p>进入多说用户中心，你就可以看到所有评论，可以进行删除、回复等.</p>
<h3 id="7-展望"><a href="#7-展望" class="headerlink" title="7. 展望"></a>7. 展望</h3><p>总的说来，多说还是不错，起码“快”，现在与Jekyll结合，唯一的不足是在Jekyll中无法查看评论整体情况，比如“最近的评论”，“每个文章多少评论”，这是后期需要思考的. 现在先到这里，欢迎吐槽.</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/04/21/2015-04-21-TCP服务端与客户端DEMO/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/04/21/2015-04-21-TCP服务端与客户端DEMO/" itemprop="url">TCP服务端与客户端DEMO</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-04-21T00:00:00+08:00">
                2015-04-21
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/后端/" itemprop="url" rel="index">
                    <span itemprop="name">后端</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>最近在整理SOCKET这块知识，发现好久不写，都忘了差不多了，这里给出服务端与客户端的DEMO，以便后面使用, 代码猛戳<a href="https://github.com/smallmuou/tcp_server_client_demo" target="_blank" rel="noopener">这里</a>.</p>
<h3 id="服务器"><a href="#服务器" class="headerlink" title="服务器"></a>服务器</h3><pre>
#include < stdio.h>  
#include < stdlib.h>  
#include < string.h>  
#include < unistd.h>  
#include < sys/types.h>  
#include < sys/socket.h>  
#include < netinet/in.h>  
#include < arpa/inet.h>  
#include < signal.h>
#include < pthread.h>
#include < fcntl.h>
#include < sys/select.h>

void sigint_handle(int sig);
int socket_init();
void socket_deinit(int fd);
void socket_process(int clientfd);
void socket_accept(int fd);

unsigned char quit = 0;

int main(int argc, char* argv[]) {
    if (argc != 2) {
        printf("Usage: %s < Listen Port>\n", argv[0]);
        return -1;
    }

    signal(SIGINT, sigint_handle);

    int listenfd = socket_init(atoi(argv[1]));
    if (listenfd < 0) {
        exit(-1);
    }

    socket_accept(li
    stenfd);
    socket_deinit(listenfd);

void sigint_handle(int sig) {
    quit = 1;
}

int socket_init(int port) {
    int fd = socket(AF_INET, SOCK_STREAM, 0);
    if (fd < 0) {
        printf("socket create failed.\n");
        goto _error;
    }

    //reuse address
    int opt = SO_REUSEADDR;
    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); 

    //bind
    struct sockaddr_in addr;  
    bzero(&addr, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(port);
    addr.sin_addr.s_addr = htonl(INADDR_ANY);
    if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
        printf("socket bind failed.\n");
        goto _error;
    }

    //listen
    if(listen(fd, 10) < 0) {
        printf("socket listen failed.\n");
        goto _error;
    }  

    return fd;
_error:
    socket_deinit(fd);
    return -1;
}

void socket_accept(int fd) {
    struct sockaddr_in client_addr;
    socklen_t addrlen;
    fd_set fds;
    struct timeval timeout = {3, 0};

    while (!quit) {
        FD_ZERO(&fds);
        FD_SET(fd, &fds);
        int ret = select(fd+1, &fds, &fds, NULL, &timeout);
        if (ret < 0) {
            break;
        } else if (ret == 0) {
            continue;
        } else {
            int clientfd = accept(fd, (struct sockaddr*)&client_addr, &addrlen);
            if (clientfd < 0) {
                printf("socket accept failed.\n");
                break;
            }

            printf("Accept: %s:%d\n", inet_ntoa(client_addr.sin_addr), htons(client_addr.sin_port));
            socket_process(clientfd);
        }
    }
}

static void* thread_proc(void* arg) {
    int clientfd = (int)arg;
    if (clientfd < 0) return NULL;

    send(clientfd, "Welcome", 8, 0);

    close(clientfd);
    return NULL;
}

void socket_process(int clientfd) {
    pthread_t pid;
    int error = pthread_create(&pid, NULL, thread_proc, (void*)clientfd);
    if (error) {
        printf("pthread create failed:%d\n", error);
    }
}

void socket_deinit(int fd) {
    if (fd >= 0) close(fd);
}

</pre>

<h3 id="客户端"><a href="#客户端" class="headerlink" title="客户端"></a>客户端</h3><pre>
#include < stdio.h>
#include < unistd.h>
#include < stdlib.h>
#include < sys/socket.h>
#include < arpa/inet.h>
#include < sys/types.h>
#include < netinet/in.h>  
#include < fcntl.h>
#include < strings.h>

int socket_init();
void socket_deinit();
void socket_connect(int fd, char* ip, int port);

int main(int argc, char* argv[]) {
    if (argc != 3) {
        printf("Usage: %s < Server IP> < Server Port>\n", argv[0]);
        return -1;
    }

    int sockfd = socket_init();
    socket_connect(sockfd, argv[1], atoi(argv[2]));
    printf("Connected to %s\n", argv[1]);

    char buf[1024] = {0};
    int len = recv(sockfd, buf, sizeof(buf), 0);
    if (len >= 0) {
        buf[len] = '\0';
    }
    printf("RECV: %s\n", buf);

    socket_deinit(sockfd);
    return 0;
}

void socket_connect(int fd, char* ip, int port) {
    struct sockaddr_in addr;
    socklen_t addrlen = sizeof(addr);

    bzero(&addr, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(port);
    addr.sin_addr.s_addr = inet_addr(ip);

    if (connect(fd, (struct sockaddr*)&addr, addrlen) < 0) {
        perror("socket connect failed");
        exit(-1);
    }
}

int socket_init() {
    int fd = socket(AF_INET, SOCK_STREAM, 0);
    if (fd < 0) {
        perror("socket create failed.");
        exit(-1);
    }

    return fd;
}

void socket_deinit(int fd) {
    if (fd >= 0) close(fd);
}

</pre>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/04/18/2015-04-18-亲爱的方，致你的第二封信/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/04/18/2015-04-18-亲爱的方，致你的第二封信/" itemprop="url">亲爱的方，致你的第二封信</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-04-18T00:00:00+08:00">
                2015-04-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/其他/" itemprop="url" rel="index">
                    <span itemprop="name">其他</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>亲爱的方:<br>我不知你是否看了我前天写的信，我知道事情发展成这样，可以说都是我的错，这里我再次给你说声“对不起”、 “对不起”、”对不起” …</p>
<p>是问题，那就得解决，一味的逃避，远远是无法成长的，那么回到问题本身，其实那晚当我看到你发的:</p>
<p><pre><br>方  22:55:29<br>未来的路很长，漫漫而遥不可及<br>方  22:56:56<br>我看到的未来，就如同现在；也许更差<br>方  22:57:25<br>依旧平淡、乏味<br>方  22:57:43<br>没有生机<br>方  22:58:20<br>没有浪漫的气息<br>方  22:58:42<br>没有感动的时刻<br></pre><br>我确实也震惊了，回想起来，我确实没给你过太多浪漫的时刻，但在这里我想表达下自己对于爱情的理解，我所理解的爱情是一方可以为另一方去奉献所有，即使是死，我想也无怨无悔. 对于你，我希望用我的一生去守护你，不让你累着，不让你饿着，不让你冻着，有好吃的给你留着，就比如那次我给你送衣服，我想这也是出于本心，因为我怕你被冻坏。你也知道，我家本身也不是很富有，要房子没房子，要车子没车子，可以说我亏欠你的太多，你愿意跟我，我也非常开心. 对于我自己，在没有你以前，你也知道，我穿的可能就像街头流浪汉，你也可以说没有品位，但你要想想，我穿的都是不上百元的衣服，我记得有一次，是20块不到买的好几件短袖，为什么是这样，因为我看到了我父母是怎么节俭的，但是现在我也渐渐放开了，也会去买一些好衣服好鞋子，而每年回去过年我爸妈问我这件衣服多少钱、这条裤子多少钱，我总给他们撒个谎，把一千来块的衣服硬说成一两百，这样我想他们会安心点，因为他们远远想不到我的一件衣服可能是他们好几个月的生活费。话说回来，就算现在，在你没在我这边的时候，我也很少去买水果、去逛街购物，吃饭总是尽量自己煮，因为我觉得这样可以多省下些钱，可以早日买个房子，给你一个稳当的家。</p>
<p>而另一个方面，对于我，又是容易满足的，即使是你小小的一个笑，我都会认为那是世上最幸福的事，也许你可能会认为没追求，但在我心里，这已经足够了。正所谓“知足常乐”，人来这个世上是为啥，要为那么多琐事而烦恼吗，在我记忆里，我感觉你好多时候都是不开心的，今天可能因为别人的一个小缺点，把自己气的头昏脑涨，明天可能又因为别人的一个小错误，而把自己气的暴跳如雷，其实，我也想过，可能你太在意，要求太严格了，当然这是好事，但我觉得没必要拿被人的错误来惩罚自己，伤己也伤人. 其实我自己原来也是类似你这样的人，即使是一件小事，也会斤斤计较，但后来我渐渐看开了，任何事物都有两面性，也许我们可以试着往好的一面看看。</p>
<p>对于爱情，总归要归于平淡，要归于生活琐事，但只有在平淡中，才能真正得到考验。</p>
<p>这是我对于爱情的理解，但也可能不是爱情。</p>
<p>—记于 2015.4.18 （许）</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/04/17/2015-04-17-利用七牛自动同步文件/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/04/17/2015-04-17-利用七牛自动同步文件/" itemprop="url">利用七牛自动同步文件</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-04-17T00:00:00+08:00">
                2015-04-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/SHELL/" itemprop="url" rel="index">
                    <span itemprop="name">SHELL</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>在写围脖的时候，有时需要关联图片，而对于Markdown来说，又没有办法直接贴图片，需要将图片上传到一个网站上，之后再取图片的链接，利用[!image]来关联图片，感觉还是挺麻烦的，后面做项目时，同事有用七牛服务器做存储，发现是个好东西，不仅能够方便上传图片，而且容易提供外链，非常方面，可惜的是体验用户只有1G空间，不过对于写围脖来说还是够用的. 下面我来说说如何实现自动同步.</p>
<h3 id="1-安装七牛工具包"><a href="#1-安装七牛工具包" class="headerlink" title="1. 安装七牛工具包"></a>1. 安装七牛工具包</h3><p>大家可以到<a href="http://developer.qiniu.com/docs/v6/tools/qrsync.html" target="_blank" rel="noopener">此</a>下载qrsync，解压后会有如下几个文件:</p>
<pre>
-rwxr-xr-x  1 starnet  staff   9607820 Jun 30  2014 qboxrsctl
-rwxr-xr-x  1 starnet  staff   2543904 Jun 30  2014 qetag
-rwxr-xr-x  1 starnet  staff   8394344 Jun 30  2014 qrsboxcli
-rwxr-xr-x  1 starnet  staff  12006444 Jun 30  2014 qrsync
</pre>
将这些文件拷贝到/usr/bin中
<pre>
sudo cp qrs* /usr/bin/
</pre>

<h3 id="2-编写qiniu-conf"><a href="#2-编写qiniu-conf" class="headerlink" title="2. 编写qiniu.conf"></a>2. 编写qiniu.conf</h3><pre>
{
    "src":Dir,
    "dest":         "qiniu:access_key=AccessKey&secret_key=SecretKey&bucket=Bucket",
    "deletable":0,
    "debug_level":1
}
</pre>
* Dir - 要同步的目录路径
* AccessKey - 七牛账号的AccessKey
* SecretKey - 七牛账号的SecretKey
* Bucket - 空间名

关于AccessKey、SecretKey和Bucket你可以登录到七牛账号里查看.

### 3. 编写同步脚本
编写一个shell脚本，如下
<pre>
qrsync ~/qiniu.conf
</pre>

<h3 id="4-自动同步"><a href="#4-自动同步" class="headerlink" title="4. 自动同步"></a>4. 自动同步</h3><p>crontab -e</p>
<pre>
0 * * * * /Users/starnet/xtool/qiniu_sync.sh
</pre>

<h3 id="5-访问"><a href="#5-访问" class="headerlink" title="5. 访问"></a>5. 访问</h3><p>默认的七牛共享域名是7ximmr.com1.z0.glb.clouddn.com，如下是你同步的文件对应的外链地址</p>
<pre>
http://7ximmr.com1.z0.glb.clouddn.com/文件名
</pre>


          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/04/16/2015-04-16-MACOSX之NFS服务器搭建/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/04/16/2015-04-16-MACOSX之NFS服务器搭建/" itemprop="url">MACOSX之NFS服务器搭建</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-04-16T00:00:00+08:00">
                2015-04-16
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>NFS即网络文件系统，允许一个系统在网络上与它人共享目录和文件，通过mount可以将它挂载点本地节点，就可以方便访问远程文件. MACOSX如何搭建NFS服务器呢？</p>
<ol>
<li><p>编辑exports</p>
 <pre>
 sudo vi /etc/exports

 /Users -network 192.168.0.0 -mask 255.255.0.0
</pre>
</li>
<li><p>启用nfsd</p>
 <pre>
 sudo nfsd enable
 </pre></li>
<li>测试验证 <pre>
 showmount -e
 </pre>
</li>
</ol>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/blog/page/16/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/blog/">1</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/16/">16</a><span class="page-number current">17</span><a class="page-number" href="/blog/page/18/">18</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/20/">20</a><a class="extend next" rel="next" href="/blog/page/18/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">smallmuou</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">197</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/smallmuou" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-globe"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">smallmuou</span>

  
</div>

    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

    <span id="busuanzi_container_site_pv">总访问量<span id="busuanzi_value_site_pv"></span>次</span>
    <span class="post-meta-divider">|</span>



  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  

  

  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
